<?php

class Options {


	function __construct() {
		
		if(!get_option('pagelines_options')) $this->default_options();
		
		$this->get_options();
		
	}
	
	function get_options() {
		$saved_options = maybe_unserialize(get_option('pagelines_options'));
		
		if (!empty($saved_options) && is_object($saved_options)) {
			foreach ($saved_options as $option_name => $value)
				$this->$option_name = stripslashes_deep($value);
		}
	}
	function update_option($name, $data = false){
		if($data) $this->$name = $data;
		else $this->$name = $_POST[$name];
	}
	
	function save_options() {
		//checkauthority();		
		update_option('pagelines_options', $this);
	}
	
	function restore_features(){
		//if they get messed up
		
		$this->features = get_default_features();
		$this->fboxes = get_default_fboxes();
		
		$this->save_options();
	}
	function restore_options(){
		//if they get messed up
		
		$this->default_options();
		
		if(VPRO) $this->vpro_defaults();
		
		$this->save_options();
	}
	function default_options(){
			// admin	
			$this->credlink = "http://www.pagelines.com";
			
			$linkno = rand(1,5);
			if($linkno == 1){ $this->credtext = "best wordpress themes";
			}elseif($linkno == 3){ $this->credtext = "CMS wordpress themes";
			}else{ $this->credtext = "website templates";}
			
			$this->credname = 'PageLines';
			$this->themeversion = 3.0;
		
			//header
			$this->custom_header = '';
			
			//posts
			$this->excerpts = true;
			$this->excerptshide = false;
			$this->excerptshidesingle = '';
			$this->authorinfo = true;
			
			//icons			
			$this->rsslink = true;
			
			$this->linkedinlink = '';
			
			$this->facebooklink = '';
			
			$this->twitterlink = '';
			$this->twittername = 'UrTweetAccount';
			
			
			
			// Color
			$this->colorscheme = 'blue';
			$this->linkcolor = '';
			$this->headercolor = '';
			$this->metacolor = '';
			$this->metacolorlink = '';
			$this->metacolortext = '';
			
			//layout 
			$this->pagetitles = '';
			
			
			//scripts 
			$this->customcss = "";
			$this->footerscripts = "";
			$this->headerscripts = "";
		
			//sidebar 
				$this->showads = false;
				$this->adslink = '';
				$this->grandnav = true;
				
			//footer
			$this->bottom_sidebars = true; 
			$this->footnav = true; 
			$this->terms = '&copy; '.date('Y').' '.SITENAME;

			//header images
			$this->favicon = ROOT."/images/favicon-pagelines.ico"; 
			$this->touchicon = "";
			
			//welcome message
			$mysitefeed = RSSURL;
			$this->greeting = "Welcome to ".SITENAME."."; 
			$this->welcomemessage = "Thanks for dropping by! Feel free to join the discussion by leaving comments, and stay updated by subscribing to the <a href='{$mysitefeed}'>RSS feed</a>.";
			
			$this->save_options();
	}
	
	function vpro_defaults(){
		
		//features
		$this->features = get_default_features();
		$this->fboxes = get_default_fboxes();
		$this->fspeed = 1500;
		$this->timeout = 0;
		
		$this->save_options();
	}
}

function pagelines($option){
	global $pagelines; 
	return $pagelines->$option;
}

function get_default_features(){
	return array(
			'1' => array(
					'name'=>'feature1',
		        	'title' => '<h3 class="fsub">Welcome to </h3><h1 class="ftitle">'.THEMENAME.'</h1>',
		        	'text' => '<p>Edit this in the admin. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam quis molestie nunc. Consectetur adipiscing elit.</p>',
		        	'media' => '<img src="'.IMAGE_FOLDER.'/feature1.jpg" alt="feature1" />',
		        	'link' => '#'
		    ),
			'2' => array(
					'name'=>'feature2',
		        	'title' => '<br/><h3 class="fsub">Make An </h3><h1 class="ftitle">Impression</h1>',
		        	'text' => '<p>Edit this in the admin. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam quis molestie nunc. Consectetur adipiscing elit.</p>',
		        	'media' => '<object width="610" height="340"><param name="movie" value="http://www.youtube.com/v/Kza-iTe2100&hl=en&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Kza-iTe2100&hl=en&fs=1&showinfo=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="610" height="340"></embed></object>',
		        	'link' => '#'
		    ),
			'3' => array(
					'name'=>'feature3',
		        	'title' => '<br/><h3 class="fsub">Wordpress Theme By</h3><h1 class="ftitle">PageLines</h1>',
		        	'text' => '<p>Edit this in the admin. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam quis molestie nunc. Consectetur adipiscing elit.</p><p><a href="http://www.pagelines.com" class="featurelink">More</a></p>',
		        	'media' => '<img src="'.IMAGE_FOLDER.'/feature2.jpg" alt="feature2" />',
		        	'link' => ''
		    ),
			'4' => array(
					'name'=>'feature4',
		        	'title' => '',
		        	'text' => '',
		        	'media' => '',
		        	'link' => ''
		    ),
			'5' => array(
					'name'=>'feature5',
		        	'title' => '',
		        	'text' => '',
		        	'media' => '',
		        	'link' => ''
		    )
	);
}

function get_default_fboxes(){
	return array(
		'1' => array(
				'name'=>'fbox1',
	        	'title' => '<h3>You\'ll love this theme</h3>',
	        	'text' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et nulla diam, ac interdum nisl. Nunc mattis tincidunt dictum. Etiam luctus consequat ipsum,</p><p><img alt="fbox1" class="aligncenter" src="'.IMAGE_FOLDER.'/fbox1.png" /></p>'
	    ),
		'2' => array(
				'name'=>'fbox2',
	        	'title' => '<h3>PageLines Themes</h3>',
	        	'text' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et nulla diam, ac interdum nisl. Nunc mattis tincidunt dictum. Etiam luctus consequat ipsum,</p><p><img alt="fbox2" class="aligncenter" src="'.IMAGE_FOLDER.'/fbox2.png" /></p>'
	    ),
		'3' => array(
				'name'=>'fbox3',
	        	'title' => '<h3>Thanks!</h3>',
	        	'text' => '<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. In et nulla diam, ac interdum nisl. Nunc mattis tincidunt dictum. Etiam luctus consequat ipsum,</p><p><img alt="fbox3" class="aligncenter" src="'.IMAGE_FOLDER.'/fbox3.png" /></p>'
	    )
	);
}
?>